package com.zsy.petshop_01;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@SpringBootApplication
@MapperScan("com.zsy.petshop_01.dao.mapper")
@ServletComponentScan
@EnableScheduling
public class PetShop01Application implements WebMvcConfigurer {
	public static void main(String[] args) {
		SpringApplication.run(PetShop01Application.class, args);
	}

	@Override
	public void addCorsMappings(CorsRegistry registry) {
		registry.addMapping("/**") // 允许所有路径
				.allowedOriginPatterns("*") // 允许的源
				.allowedMethods("GET", "POST", "PUT", "DELETE") // 允许的请求方法
				.allowedHeaders("*") // 允许的请求头
				.allowCredentials(true); // 允许发送凭证，如 cookies
	}
}
